﻿@using Sovigaz
@{
    ViewBag.Title = "Chi tiết lệnh điều xe";
    var url = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/');
}
<script>
    app.controller('CommandController', function ($scope, $compile, $http, $filter, service) {

        $scope.load = function () {
            startloading($('#content'));

            var url = '@url' + '@Url.Action("CommandApi", "Api", new {id = Model})';

            $http.get(url)
                .success(function (data) {
                    $scope.command = data;
                    $scope.command.Date = $filter('date')(Date.parse($scope.command.Date), 'dd/MM/y');
                    stoploading($('#content'));
                })
                .error(function (data) {
                    stoploading($('#content'));
                    service.showModal($scope, $compile, 'error', data);
                });
        };

        $scope.refresh = function () {
            $scope.load();
        };

        $scope.add = function () {
            window.location = '@Url.Action("Detail", "Command", new { id = String.Empty })';
        };

        $scope.save = function () {           
            var url = '@url' + '@Url.Action("CommandApi", "Api")';
            $http.put(url, $scope.command)
                .success(function(data) {
                    if (@Model === 0) {
                        window.location = '@Url.Action("Detail", "Command")/' + data.CommandID;
                    }
                    $scope.command = data;

                    stoploading($('#content'));
                    service.showModal($scope, $compile, 'notify', 'Dữ liệu đã được lưu thành công!!!');
                })
                .error(function(data) {
                    stoploading($('#content'));
                    service.showModal($scope, $compile, 'error', data);
                });
        };

        $scope.confirmDelete = function () {
            service.showModal($scope, $compile, 'confirm', 'Bạn có chắc chắn muốn xóa dữ liệu?', 'delete()');
        };

        $scope.back = function () {
            window.location = '@Url.Action("Index", "Command")';
        };

        $scope.sizes = [{}];
        $scope.sizes['N'] = 'Nhỏ';
        $scope.sizes['L'] = 'Lớn';

        $scope.load();
    });

    $(function () {
        $("[data-toggle=tooltip]").tooltip();
    });
</script>

<div ng-controller="CommandController">
    @Html.Partial("_PageHeader")
    @Html.Partial("_ToolbarDetail")
    <div id="content" class="content row">
        <form role="form" name="form" autocomplete="off">
            <div class="panel-body">
                <div class="col-lg-2">
                    @Html.Partial("Control/_Control_TextBox_Disabled", new Dictionary<string, string>
                    {
                        {"Text", "Mã số phiếu"},
                        {"Model", "command.CommandCode"},
                        {"Name", "commandCode"},
                    })
                </div>
                <div class="col-lg-2">
                    @Html.Partial("Control/_Control_TextBox_Disabled", new Dictionary<string, string>
                    {
                        {"Text", "Mã số kế hoạch"},
                        {"Model", "command.DeliveryPlanCode"},
                        {"Name", "deliveryPlanCode"},
                    })
                </div>
                <div class="col-lg-2" >
                    @Html.Partial("Control/_Control_TextBox_Disabled", new Dictionary<string, string>
                    {
                        {"Text", "Ngày giao"},
                        {"Model", "command.Date"},
                        {"Name", "date"}
                    })
                </div>
                <div class="col-lg-2">
                    @Html.Partial("Control/_Control_TextBox_Disabled", new Dictionary<string, string>
                    {
                        {"Text", "Số xe"},
                        {"Model", "command.LicensePlate"},
                        {"Name", "licensePlate"}
                    })
                </div>
                <div class="col-lg-8" style="clear: both">
                    @Html.Partial("Control/_Control_TextBox_Disabled", new Dictionary<string, string>
                    {
                        {"Text", "Tài xế-Bốc xếp"},
                        {"Model", "command.TaixeBocxep"},
                        {"Name", "TaixeBocxep"}
                    })
                </div>                
                
                <div class="col-lg-8" style="clear: both">
                    @Html.Partial("Control/_Control_TextArea_Disabled", new Dictionary<string, string>
                    {
                        {"Text", "Ghi chú"},
                        {"Model", "command.Description"},
                        {"Name", "description"}
                    })
                </div>              
                <div class="col-lg-8" style="clear: both; border-top: 1px solid lightgray; margin-top: 10px; margin-bottom: 10px">

                </div>
                <div class="col-lg-8" style="clear: both">
                    <b>Chi tiết vận chuyển</b>
                </div>
                <div class="col-lg-12" style="clear: both">
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover">
                            <colgroup>
                                <col />
                                <col style="width: 150px" />
                                <col style="width: 150px" />
                                <col style="width: 150px" />
                                <col style="width: 150px" />
                            </colgroup>
                            <thead>
                                <tr>
                                    <th>
                                        Khách hàng
                                    </th>
                                    <th>
                                        SL kế hoạch
                                    </th>
                                    <th>
                                        SL thực giao
                                    </th>
                                    <th>
                                        SL nhận về
                                    </th>
                                    <th>
                                        SL trả về
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ng-repeat="item in command.CommandLines">
                                    <td>{{item.PartnerName}}</td>
                                    <td>{{item.PlanQty}}</td>
                                    <td>{{item.ShippedQty}}</td>
                                    <td>{{item.ReceivedEmptyQty}}</td>
                                    <td>{{item.ReceivedFullQty}}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>